<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
        
        function Calculator(){
            this.method  = {
                '+' : (a,b) => a + b,
                '-' : (a,b) => a - b,
                '*' : (a,b) => a * b,
                '/' : (a,b) => a / b,
                '**': (a,b) => a ** b,
                '^' : (a,b) => Math.pow(a,b) 
            }
            this.calculate = function(str){
                let arr = str.split(' ');
                    if(this.method[arr[1]]){
                        return this.method[arr[1]](Number(arr[0]),Number(arr[2]));
                }
            }
            this.addMethod = function(type,fun){
                this.method[type] = fun;
            }
        }
        let calu = new Calculator();
        // console.log(calu.calculate("3 + 7"));
        console.log(calu.calculate('2 ** 3'));
    </script>
</body>
</html>